package com.xigua.juc;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2021/8/1116:16
 */
public class DoubleCheckLock {
    public static volatile boolean initFlag = false;
    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            System.out.println("waiting data");
            while (!initFlag){
            }
            System.out.println("=================success");
        }).start();
        Thread.sleep(3000);
        new Thread(()->prepareData()).start();
    }

    public static void prepareData(){
        System.out.println("prepare data...");
        initFlag = true;
        System.out.println("prepare data end");
    }

}
